unit UfrmOrderDetailView;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBClient, DBGridEhGrouping, GridsEh, DBGridEh,RLLibrary_Intf;

type
  TfrmOrderDetailView = class(TForm)
    cdsOrderDetail: TClientDataSet;
    dsOrderDetail: TDataSource;
    DBGridEhOrderDetail: TDBGridEh;
    cdsOrderDetailproductnumber: TStringField;
    cdsOrderDetailproductname: TStringField;
    cdsOrderDetailproductmodel: TStringField;
    cdsOrderDetailproductarea: TStringField;
    cdsOrderDetailproductunit: TStringField;
    cdsOrderDetailamount: TFloatField;
    cdsOrderDetailtaxprice: TFloatField;
    cdsOrderDetailnotaxprice: TFloatField;
    cdsOrderDetailtotalsum: TFloatField;
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure cdsOrderDetailCalcFields(DataSet: TDataSet);
  private
    FOrderID:Integer;
    FOrderService:IOrderService;
  public
     property OrderId:Integer  write FOrderID;
  end;

var
  frmOrderDetailView: TfrmOrderDetailView;

implementation

uses Udatamodule,uROBinaryHelpers;

{$R *.dfm}

procedure TfrmOrderDetailView.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#27 then  Close;
end;

procedure TfrmOrderDetailView.FormCreate(Sender: TObject);
begin
   FOrderService:=dm.GetIOrder;
end;

procedure TfrmOrderDetailView.FormShow(Sender: TObject);
begin
     cdsOrderDetail.DisableControls;
     cdsOrderDetail.Data:=VariantFromBinary(  FOrderService.GetOrderListByOrderID(FOrderID));
     cdsOrderDetail.EnableControls;
end;

procedure TfrmOrderDetailView.cdsOrderDetailCalcFields(DataSet: TDataSet);
begin
   DataSet.FieldByName('totalsum').Value:= DataSet.FieldByName('notaxprice').Value  *
                                          DataSet.FieldByName('amount').Value;
end;

end.
